<?php
require_once('config.php');
require_once('db.php');
$Name = $_POST['Name'];
$Port = $_POST['Port'];
$id = $_POST['id'];
// Connect to server and select database.
$link = connectdb($servername,$dbname,$dbusername,$dbpassword);

// update data in mysql database
$sql="UPDATE protocols SET name='$Name', port='$Port' WHERE id=$id";
$result=mysql_query($sql, $link);

// if successfully updated.
if($result){
	$message = urldecode("<b>Update successfully</b>");
	header("Location: protocols.php?id=$id&message=" . $message);		
}else {
	$message = urldecode("There is an MySQL error occurred: <b>" . mysql_error($link) . "</b>");
	close($link);
	header("Location: updateprotocol.php?id=$id&message=" . $message);	
}

?>